//
//  SongMenuTableViewCell.m
//  CapriceMusic
//
//  Created by dllo on 16/1/9.
//  Copyright © 2016年 MYX. All rights reserved.
//
#import "SongMenuTableViewCell.h"

@implementation SongMenuTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.myImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.myImageView.layer.cornerRadius = 12;
        self.myImageView.contentMode = UIViewContentModeScaleAspectFill;
        self.myImageView.clipsToBounds = YES;
        [self addSubview:self.myImageView];
        
        self.mvName = [[UILabel alloc] initWithFrame:CGRectZero];
        self.mvName.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.mvName];
        
        self.embodyLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.embodyLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.embodyLabel];
        
        self.integralLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        self.integralLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.integralLabel];
        
        self.playNumber = [[UILabel alloc] initWithFrame:CGRectZero];
        self.playNumber.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.playNumber];
        
        self.userName = [[UILabel alloc] initWithFrame:CGRectZero];
        self.userName.font = [UIFont systemFontOfSize:12];
        self.userName.textAlignment = NSTextAlignmentRight;
        self.userName.textColor = [UIColor colorWithRed:30 / 255.0 green:195 / 255.0 blue:153 / 255.0 alpha:1.0];
        [self addSubview:self.userName];
        
        self.userImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.userImage.contentMode = UIViewContentModeScaleAspectFill;
        self.userImage.layer.cornerRadius = 15;
        self.userImage.clipsToBounds = YES;
        [self addSubview:self.userImage];
        
        if (self.width <= 320) {
            self.kWidth = 10;
        }else {
            self.kWidth = 15;
        }
    }
    return self;
}

- (void)setMvModel:(searchMVModel *)mvModel {
    if (_mvModel != mvModel) {
        _mvModel = mvModel;
    }
    [self.myImageView sd_setImageWithURL:[NSURL URLWithString:mvModel.playListBigPic]];
    
    self.mvName.text = mvModel.title;

    self.embodyLabel.text = [NSString stringWithFormat:@"收录高清MV%@首", mvModel.videoCount.stringValue];


    self.integralLabel.text = [NSString stringWithFormat:@"获得积分总数%@", mvModel.integral.stringValue];
    
    self.playNumber.text = [NSString stringWithFormat:@"播放次数%@", mvModel.totalViews.stringValue];

    self.userName.text = mvModel.creator[@"nickName"];
    
    [self.userImage sd_setImageWithURL:[NSURL URLWithString:mvModel.creator[@"largeAvatar"]]];
}

- (void)layoutSubviews {
    [super layoutSubviews];

    self.myImageView.frame = CGRectMake(0, 0, self.height, self.height - 2);
    
    self.mvName.frame = CGRectMake(self.myImageView.right + 5, self.kWidth, self.width - self.myImageView.width, 10);
    
    self.embodyLabel.frame = CGRectMake(self.mvName.origin.x, self.mvName.bottom + self.kWidth, self.mvName.width, 10);
    
    self.integralLabel.frame = CGRectMake(self.embodyLabel.origin.x, self.embodyLabel.bottom + self.kWidth, self.embodyLabel.width, 10);
    
    self.playNumber.frame = CGRectMake(self.integralLabel.origin.x, self.integralLabel.bottom + self.kWidth, self.integralLabel.width, 10);
    
    self.userImage.frame = CGRectMake(self.width - 35, self.height - 40, 30, 30);
    
    self.userName.frame = CGRectMake(self.myImageView.right, self.userImage.origin.y + 10, self.width - self.myImageView.width - self.userImage.width - 5, 10);
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
